//
//  HomeMindDataCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/21.
//

#import "HomeMindDataCell.h"

@interface HomeMindDataCell()
@property (nonatomic,strong) UIView * bgView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UILabel * numLabel;
@property (nonatomic,strong) UILabel * typeLabel;
@end

@implementation HomeMindDataCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubViewLayout];
    }
    return self;
}
-(void)setSubViewLayout{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    
    [self addSubview:self.bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(@0);
        make.size.mas_offset(CGSizeMake(300 * FMScaleX, 24 * FMScaleX));
    }];
    [self.bgView addSubview:self.nameLabel];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(@0);
        make.left.mas_offset(10 * FMScaleX);
    }];
    [self.bgView addSubview:self.numLabel];
    [_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(@0);
    }];
    [self.bgView addSubview:self.typeLabel];
    [_typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-20);
        make.centerY.equalTo(@0);
    }];
}

-(void)setInfoModel:(HomePsychologyModel *)infoModel{
    
    self.nameLabel.text = infoModel.name;
    self.numLabel.text = [NSString stringWithFormat:@"评估值：%ld",infoModel.num];
    [self setStyleAndInfo:infoModel.num];
}

-(void)setAttModel:(HomeAllAttackModel *)attModel{
    
    self.nameLabel.text = attModel.name;
    self.numLabel.text = [NSString stringWithFormat:@"评估值：%ld",attModel.num];
    [self setStyleAndInfo:attModel.num];
    
}

-(void)setStyleAndInfo:(NSInteger)num{
    
    
    if (num > 0 && num <= 20) {
        self.typeLabel.text = @"微显性";
        self.bgView.backgroundColor = RDRGBA(0x6FBBA4, 0.1);
        self.typeLabel.textColor = RDRGB(0x6FBBA4);
        self.numLabel.textColor = RDRGB(0x6FBBA4);
    }else if (num > 20 && num <= 60 ){
        self.typeLabel.text = @"弱显性";
        self.bgView.backgroundColor = RDRGBA(0xF3B66E, 0.1);
        self.typeLabel.textColor = RDRGB(0xF3B66E);
        self.numLabel.textColor = RDRGB(0xF3B66E);
    }else{
        self.typeLabel.text = @"显性";
        self.bgView.backgroundColor = RDRGBA(0xF2A895, 0.1);
        self.typeLabel.textColor = RDRGB(0xF2A895);
        self.numLabel.textColor = RDRGB(0xF2A895);
    }
    
}


-(UIView *)bgView{
    
    if (!_bgView) {
        _bgView = [[UIView alloc]init];
        _bgView.backgroundColor = RDRGBA(0x6FBBA4, 0.1);
        [_bgView setCornerRadius:4 * FMScaleX];
    }
    return _bgView;
}
-(UILabel *)nameLabel{
    
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.textColor = RDRGB(0x555555);
        _nameLabel.font = Medium(13);
    }
    return _nameLabel;
}
-(UILabel *)numLabel{
    
    if (!_numLabel) {
        _numLabel = [[UILabel alloc]init];
        _numLabel.font = Regular(12);
        _numLabel.textColor = RDRGB(0x6FBBA4);
    }
    return _numLabel;
}
-(UILabel *)typeLabel{
    
    if (!_typeLabel) {
        _typeLabel = [[UILabel alloc]init];
        _typeLabel.font = Regular(12);
        _typeLabel.textColor = RDRGB(0x6FBBA4);
    }
    return _typeLabel;
}
@end
